package com.drinks.yiniang.common.recycler.decoration;

import android.graphics.Rect;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.drinks.yiniang.App;
import com.hansen.library.utils.ScreenSizeUtils;

/**
 * Created by han on 2019/6/20 0020.
 */

public class DraftsPhotosItemDecoration extends RecyclerView.ItemDecoration {
    private int mSpace;

    public DraftsPhotosItemDecoration(int space) {
        this.mSpace = space;
    }

    public static DraftsPhotosItemDecoration getItemDPDecoration(int space) {
        space = ScreenSizeUtils.dp2px(App.getInstance().getApplicationContext(), space);

        return new DraftsPhotosItemDecoration(space);
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        if(parent.getChildLayoutPosition(view) == 0) {
            outRect.left = mSpace;
            outRect.right = mSpace;
        } else {
            outRect.left = 0;
            outRect.right = mSpace;
        }
    }
}
